/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bill.model.dao;

import bill.model.vo.Person;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import util.DBUtils;

/**
 *
 * @author Administrator
 */
public class UserDAO {

    //public static Person getPersonbyIDAndPwd(String id,String pwd){
    public static Person getPersonbyIDAndPwd(String id){
        Person p = null;
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DBUtils.getSysConnection();
            String sql = "select cUser_Id,cUser_Name,cPassword from UA_User" + " where cUser_Id = ?";
            pstmt = con.prepareStatement(sql);
            pstmt.setString(1, id);
            //pstmt.setString(2, pwd);
            rs = pstmt.executeQuery();
            if(rs.next()){
                p = new Person();
                p.setId(rs.getString(1));
                p.setName(rs.getString(2));
                //p.setPwd(rs.getString(3));
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            DBUtils.closeAll(rs, pstmt, con);
        }
        return p;
    }

}
